Xbasic

SQL::ConnectionApplyData Method

Syntax

Result_Flag as L = ApplyData(SQLStatement as C, ResultSet as SQL::ResultSet [, EventScript as C [,SQL::TableInfo TableInfo [, MapTableInfoUsingColumnIndex = .t. as L]])

Arguments

SQLStatementCharacter

An SQL INSERT, DELETE, or UPDATE statement.

ResultSetSQL::ResultSet

A SQL::ResultSet object that contains transactions to apply.

EventScriptCharacter

Default = "". An Xbasic Script implementing any of the following functions:

UpdateBegin()
UpdateProgress()
UpdateEnd()

In each case, the Context argument is the connection itself.

TableInfoSQL::TableInfo

A SQL::TableInfo object.

MapTableInfoUsingColumnIndexLogical

Default = .t.

Returns

Result_FlagLogical

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

Description

Apply the query to a table in the currently connected database using the result set provided.

Discussion

The ApplyData() method applies inserts, updates, and deletes to a table in the currently connected database. The result set contains the transactions to apply. See SQL Events for a description of the events that can be scripted.

Example

This script creates a new table and inserts the contents of a SQL::ResultSet into the table.

dim conn as SQL::Connection
dim ti as SQL::TableInfo
dim rs as SQL::ResultSet
dim connstring as C
dim tbl as P
dim insert as C
connstring = "{A5API=Access,FileName='C:\Program Files\A5V8\MDBFiles\Alphasports.mdb', UserName='Admin'}"
if .not. conn.Open(connstring) then
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
if .not. SQL_TableInfoOfDBF("c:\program files\a5v8\samples\alphasports\Customer.dbf", ti) then
    ui_msg_box("Error", "Cannot populate SQL::TableInfo")
    end
end if
ti.Name = "AlphaSportsCustomer"
if .not. conn.CreateTable(ti) then
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
insert = conn.GenerateInsertStatement(ti)
tbl = table.open("c:\program files\a5v8\samples\alphasports\Customer.dbf")
rs = conn.ResultSetFromDBF(tbl)
if .not. conn.ApplyData(insert, rs)
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
tbl.close()
conn.close()

See Also